﻿using System;
using System.Web;
using System.Web.Mvc;

namespace BlueSky.Web.Binders
{
    /// <summary>
    /// HttpPostedFileBase binder class.
    /// </summary>
    public class HttpPostedFileBaseModelBinder : ModelBinderBase
    {
        /// <summary>
        /// Bind HttpPostedFileBase.
        /// </summary>
        /// <param name="controllerContext">Controller context</param>
        /// <param name="bindingContext">Binding context</param>
        /// <returns>HttpPostedFileBase object.</returns>
        public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            HttpPostedFileBase file = controllerContext.HttpContext.Request.Files[bindingContext.ModelName];
            return file;
        }
    }
}
